Next | Prev | Up | Top | Contents | Index
STREAMS Monitor
The STREAMS monitor ensures mutually exclusive access to STREAMS on multiprocessor systems. The STREAMS put, service, open, and close functions are guaranteed to have the monitor upon entry and, thus run with assured mutual exclusion. The kernel handles all monitor interactions for these procedures, although it does not acquire the monitor for STREAMS driver interrupt routines, which must acquire the monitor explicitly.
All STREAMS drivers must acquire the monitor before performing any interaction with STREAMS from interrupt level, such as quenable(), getq(), or putq(). To obtain the monitor from an interrupt routine, the driver should call:
int streams_interrupts (func,arg1,arg2,arg3)
This routine either:
- Acquires the monitor and runs func with arguments of arg1, arg2, and arg3, then releases the monitor and returns 1
or
- Queues the function on the monitor for execution once the current owner of the monitor releases it, and immediately returns 0. The example below shows how a STREAMS driver could use streams_interrupt().
There are additional changes for STREAMS drivers that use calls to timeout() and delay(), which corrupt the mutual exclusion of the monitor. To make these calls safe, the device driver writer must replace them with macros defined in the include file sys/strmp.h.
Replace all calls to timeout() with the macro STREAMS_TIMEOUT(); replace all calls to delay() with the macro STREAMS_DELAY(). For example, if the single-processor version of a driver contains the following calls:
timeout(watchdog,unit,HZ/10);
and
delay(100);
they should be replaced by:
STREAMS_TIMEOUT(watchdog,unit,HZ/10;
and
STREAMS_DELAY(100);
These macros revert to the original timeout() and delay() calls in the single processor case. The include file sys/strmp.h also defines the constant MP_STREAMS if the multiprocessor version of STREAMS is in use. This is useful for performing conditional compilation of sections of the STREAMS driver for multiprocessor systems. In any case, the use of these macros and definitions makes the driver machine-dependent.
Next | Prev | Up | Top | Contents | Index